Page({
  data: {
    topIndex: 0,
    payListArray: [{
        className: 'icon-gongziguanli',
        text: '工资',
        bgdColor: 'bgdColor'
      },
      {
        className: 'icon-38',
        text: '理财',
        bgdColor: ''
      },
      {
        className: 'icon-fenxiangzhuanqian',
        text: '红包',
        bgdColor: ''
      },
      {
        className: 'icon-qian4',
        text: '兼职',
        bgdColor: ''
      },
      {
        className: 'icon-qita',
        text: '其他',
        bgdColor: ''
      }
    ],
    incomeListArray: [{
        className: 'icon-canyin',
        text: '餐饮',
        bgdColor: 'bgdColor'
      },
      {
        className: 'icon-gouwu',
        text: '购物',
        bgdColor: ''
      },
      {
        className: 'icon-clothes',
        text: '服饰',
        bgdColor: ''
      },
      {
        className: 'icon-youxi',
        text: '娱乐',
        bgdColor: ''
      },
      {
        className: 'icon-jiaotong',
        text: '交通',
        bgdColor: ''
      },
      {
        className: 'icon-lingshi',
        text: '零食',
        bgdColor: ''
      },
      {
        className: 'icon-education_icon',
        text: '教育',
        bgdColor: ''
      },
      {
        className: 'icon-tongxun-01',
        text: '通讯',
        bgdColor: ''
      },
      {
        className: 'icon-touzi',
        text: '投资',
        bgdColor: ''
      },
      {
        className: 'icon-yiliao',
        text: '医疗',
        bgdColor: ''
      },
      {
        className: 'icon-icon_xinyong_xianxing_jijin-140',
        text: '旅游',
        bgdColor: ''
      },
      {
        className: 'icon-qita',
        text: '其他',
        bgdColor: ''
      }
    ],
    //在onLoad中赋予当前日期的值
    recordTime:'',
  },
  handleClick: function (e) {
    this.setData({
      topIndex: e.currentTarget.dataset.index
    })
  },
  changeType: function (e) {
    let index = e.currentTarget.dataset.index;
    let that = this;
    //支出页面
    if (this.data.topIndex == 0) {
      var dataList = this.data.payListArray;
      for (let i = 0; i < dataList.length; i++) {
        dataList[i].bgdColor = '';
      }
      dataList[index].bgdColor = 'bgdColor';
      this.setData({
        payListArray: dataList
      })
    }
    //收入页面
    else if (this.data.topIndex == 1) {
      var dataList = this.data.incomeListArray;
      for (let i = 0; i < dataList.length; i++) {
        dataList[i].bgdColor = '';
      }
      dataList[index].bgdColor = 'bgdColor';
      this.setData({
        incomeListArray: dataList
      })
    }
  },
  onLoad:function(options){
    var date=new Date();
    var year=date.getFullYear();
    var month=date.getMonth()+1;
    var day=date.getDate();
    var time=year+'-'+month+'-'+day;
    this.setData({
      recordTime:time
    })
  }
})